import datetime
from django.utils import timezone
from django.db import models


class Request(models.Model):
  name              = models.CharField(max_length=200)
  extension         = models.CharField(max_length=200)
  pub_date          = models.DateTimeField('date published')
  short_description = models.CharField(max_length=200)
  description       = models.CharField(max_length=10000)

  def __str__(self):
    return self.name + ': ' + self.description

  def was_published_recently(self):
    now = timezone.now()
    return now - datetime.timedelta(days=1) <= self.pub_date < now

  was_published_recently.admin_order_field = 'pub_date'
  was_published_recently.boolean           = True
  was_published_recently.short_description = 'Requested recently?'

# vim:tabstop=2:softtabstop=2:shiftwidth=2
